04. From Xcode to App
The Swift Compiler
So what all happened when we hit the play button? Well, Xcode began working in the background to launch the Maze app on the iOS Simulator.
The Swift compiler makes this all happen. The Swift compiler is a piece of software that translates the Swift code we write into an executable app that a device like your phone, tablet, or watch can understand. The process by which the compiler translates your code into an executable app is known as building.
The Swift compiler is used to translate Swift code into an executable app.
Syntax: Following the Rules
In order to build an app, we have to follow the compiler’s guidelines for code, or acceptable syntax. You can think of syntax as language rules. For example, imagine that your compiler only knows the language rules for Japanese. If you tried to talk to the compiler in German, the compiler wouldn't understand what you're saying. Therefore, your code must be written in perfect Japanese in order for the compiler to translate the code and finish the building process. Otherwise, the build will fail, and the app won't run.
If syntax is invalid, then the build process cannot complete.
Building and Running
After the compiler builds our code, we have an executable app file that contains all the information needed by a device to run your app. Note: We normally don’t see the app file since Xcode conveniently manages all of this in the background.
The building process generates an executable that can be run on a device.
With the executable app complete, we move into the running phase where the app is installed and run on a device (or the iOS Simulator). You may already be familiar with the process if you've downloaded apps from the App Store; when you install an app from the App Store on a physical iOS device, the app is downloaded, and then run on your phone, tablet, or watch.